package com.xdj.chashuiwu.photography.controller;

import java.util.Arrays;
import java.util.Map;

import com.xdj.chashuiwu.photography.entity.PhotographyEntity;
import com.xdj.chashuiwu.photography.service.PhotographyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xdj.common.utils.PageUtils;
import com.xdj.common.utils.R;



/**
 * 
 *
 * @author xdj
 * @email 1226954639@qq.com
 * @date 2021-12-06 09:28:53
 */
@RestController
@RequestMapping("photography/photography")
public class PhotographyController {
    @Autowired
    private PhotographyService photographyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("photography:photography:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = photographyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{pId}")
    @RequiresPermissions("photography:photography:info")
    public R info(@PathVariable("pId") Integer pId){
		PhotographyEntity photography = photographyService.getById(pId);

        return R.ok().put("photography", photography);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("photography:photography:save")
    public R save(@RequestBody PhotographyEntity photography){
		photographyService.save(photography);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("photography:photography:update")
    public R update(@RequestBody PhotographyEntity photography){
		photographyService.updateById(photography);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("user:photography:delete")
    public R delete(@RequestBody Integer[] pIds){
		photographyService.removeByIds(Arrays.asList(pIds));

        return R.ok();
    }

}
